
namespace go thrift

struct ProtocolOption{
    /**是否开启转换为hls*/
    1: bool enable_hls,
    /**是否开启MP4录制*/
    2: bool enable_mp4,
    /**是否开启转换为rtsp/webrtc*/
    3: bool enable_rtsp,
    /**是否开启转换为rtmp/flv*/
    4: bool enable_rtmp,
    /**是否开启转换为http-ts/ws-ts*/
    5: bool enable_ts,
    /**是否开启转换为http-fmp4/ws-fmp4*/
    6: bool enable_fmp4,
    /**转协议是否开启音频*/
    7: bool enable_audio,
    /**添加静音音频，在关闭音频时，此开关无效*/
    8: bool add_mute_audio,
}
struct AddStreamProxyParam{
    1: string vhost,
    2: string app,
    3: string stream,
    /*RTMP协议的url*/
    4: string url,
	5: i32 retry_count,
	6: ProtocolOption deviceType,
    7: string tid,
}
struct DelStreamProxyParam{
    1: string key,
    2: string tid,
}
/*通用答复*/
struct CommonResponse
{
    1:  i32 code,
    2:  string msg,
}
struct GetStreamStatusRequest
{
    1: string tid,
    /*为空表示所有*/
    2: string schema,
    /*为空表示所有*/
    3: string app,

    /*为空表示所有*/
    4: string stream,
    /*调用addStreamProxy时指定的srcUrl，为空表示所有*/
    5: string srcUrl,
}
struct StreamStatResponse
{
    1:  i32 code,
    2:  string msg,
    3:  i32 readerCount,
    4:  i32 totalReaderCount,
    5:  string stream,
    6:  string originUrl,
    7:  string app,
    8:  string schema,
    9:  i64 aliveSecond,
}
struct OpenRtpServerRequest
{
    1:  i32 port,
    2:  string streamId,
    3:  bool enableTcp,
    4:  string tid,
}
struct OpenRtpServerResponse
{
    1:  i32 code,
    2:  string msg,
    3:  i32 port,
    4:  string streamId,
    5:  bool enableTcp,
}
struct MergeStreamRect
{
    1: i32 x,
    2: i32 y,
    3: i32 width,
    4: i32 height,
    5: string playUrl,
}
struct StartMergeStreamRequest
{
    1: string tid,
    2: i32 width,
    3: i32 height,
    4: list<MergeStreamRect> childRect,
    5: i32 gpuCardIndex,
    6: i32 gpuCardCount,
    7: i32 ssrc,
}
struct StartMergeStreamResponse
{
    1:  i32 code,
    2:  string msg,
    3:  string ssrc,
}
struct GetMergeStreamStatusRequest
{
    1: string ssrc,
    2: string tid,
}
enum CmdStatus
{
    Unknown,
    FailedToStart,
    Running,
    Finished,
}
struct GetMergeStreamStatusResponse
{
    1: i32 code,
    2: string msg,
    3: string ssrc,
    4: CmdStatus status,
    5: string cmdStatusTip,
}
struct StopMergeStreamRequest
{
    1: string ssrc,
    2: string tid,
}
struct StopMergeStreamResponse
{
    1: i32 code,
    2: string msg,
}
struct JobTimeAbsolute {
    1: i32 year,
    2: i32 month,
    3: i32 day,
    4: i32 hour,
    5: i32 minute,
    6: i32 second,
    7: i32 milliSecond,
}
struct JobServerInfo
{
    1: string serverIp,
    2: i32 serverPort,
    3: string otherInfo,
}
struct RealtimeSnapshotJob
{
    1: JobTimeAbsolute jobTime,
    2: string imageName,
    3: list<JobServerInfo> serverInfo,
}
enum EnumSnapshotJobStatus
{
    Unknown,
    WaitingToSnapshot,
    WaitingToDownload,
    WaitingToSend,
    SendSuccess,
    SendFailedWithoutRetry,
    WaitingToSendAgain,
}
struct SnapshotJobStatus
{
    1: JobTimeAbsolute jobTime,
    2: i32 offsetMillisecond,
    3: string imageName,
    4: list<JobServerInfo> serverInfo,
    5: EnumSnapshotJobStatus jobStatus,
}
struct AddRealtimeSnapshotRequest
{
    1: string tid,
    2: string groupId,
    3: string app,
    4: string stream,
    5: bool sendSnapshotToServer,
    6: list<RealtimeSnapshotJob> allJobs,
}
struct DelSnapshotRequest
{
    1: string tid,
    2: list<string> allGroupId,
    3: string app,
    4: string stream,
}
struct QuerySnapshotStatusRequest
{
    1: string tid,
    /**如果为空，则返回url对应的最近的groupId*/
    2: string groupId,
    /**groupId和app/stream不能同时为空*/
    3: string app,
    4: string stream,
}
struct QuerySnapshotStatusResponse
{
    /**200-查询成功并且有job； 204-查询成功但是没有job*/
    1: i32 code,
    2: string msg,
    3: string groupId,
    4: string app,
    5: string stream,
    6: bool sendSnapshotToServer,
    7: bool isRealtime,
    /**未执行的job列表*/
    8: list<SnapshotJobStatus> allJobsStatus,
}
struct HistorySnapshotJob
{
    1: i32 offsetMillisecond,
    2: string imageName,
    3: list<JobServerInfo> serverInfo,
}
struct AddHistorySnapshotRequest
{
    1: string tid,
    2: string groupId,
    3: string app,
    4: string stream,
    5: bool sendSnapshotToServer,
    6: list<HistorySnapshotJob> allJobs,
}
struct AddSnapshotResponse
{
    1:  i32 code,
    2:  string msg,
}
/**接入中心与媒体中心的thrift通信接口*/
service MediaServer{
    /**向媒体中心推流*/
    CommonResponse addStreamProxy(1: AddStreamProxyParam request),

	/**停止向媒体中心推流*/
    CommonResponse delStreamProxy(1: DelStreamProxyParam request),

    /**获取所有流的用户统计数据*/
    list<StreamStatResponse> getStreamStatus(1: GetStreamStatusRequest request),
    /**国标推流需要调用该接口传入streamId*/
    OpenRtpServerResponse openRtpServer(1: OpenRtpServerRequest request),
    /**合并视频流，请求非阻塞*/
    StartMergeStreamResponse startMergeStream(1: StartMergeStreamRequest request),
    /**查询合并视频流命令的运行状态*/
    GetMergeStreamStatusResponse getMergeStreamStatus(1: GetMergeStreamStatusRequest request),
    /**结束合并视频流*/
    StopMergeStreamResponse stopMergeStream(1: StopMergeStreamRequest request),
    /**实时预览-添加抓图任务*/
    AddSnapshotResponse addRealtimeSnapshot(1: AddRealtimeSnapshotRequest request),
    /**历史回调-添加抓图任务*/
    AddSnapshotResponse addHistorySnapshot(1: AddHistorySnapshotRequest request),
    /**实时预览或者历史回调-删除抓图任务*/
    CommonResponse delSnapshot(1: DelSnapshotRequest request),
    /**实时预览或者历史回调-查询抓图任务*/
    QuerySnapshotStatusResponse querySnapshot(1: QuerySnapshotStatusRequest request),
}
